//
//  UIImage+Extension.swift
//  Weibo28
//
//  Created by 高辰 on 16/5/20.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

extension UIImage {
    func scaleImageWithWidth(scaleWidth: CGFloat) -> UIImage {
        let scaleHeight = scaleWidth / self.size.width * self.size.height
        
        let size = CGSize(width: scaleWidth, height: scaleHeight)
        
        UIGraphicsBeginImageContext(size)
        
        self.drawInRect(CGRect(origin: CGPointZero, size: size))
        
        let scaleImage = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return scaleImage
    }
}
